import hdc_utils
import time
import os


def main():
    timestamp = time.strftime("%Y-%m-%d-%H%M%S", time.localtime())
    devices = hdc_utils.command_devices()
    for device in devices:
        base = "debug_{}_{}".format(timestamp, device)
        bluetooth = "{}/bluetooth".format(base)
        os.makedirs(base)
        os.makedirs(bluetooth)

        hdc_utils.command_pull(device, "/data/log/hilog", base)
        hdc_utils.command_pull(device, "/data/log/faultlog", base)
        hdc_utils.command_pull(device, "/data/bluetooth/log", bluetooth)
    hdc_utils.timestamp("get log finished")


if __name__ == "__main__":
    main()
